﻿using System;
using LazyLib.ActionBar;
using LazyLib.Helpers;
using LazyLib.Combat;
using LazyLib.Wow;
using Frosty.Helpers;

namespace Frosty.Combat
{
    public class PullSequence
    {
        public PullResult Pull(PUnit target)
        {
            CombatEngine.Log(string.Format("[Frosty]: Pulling {0}, Level: {1}, Health: {2}%, Skinnable: {3}.", target.Name, target.Level, target.Health, Functions.IsSkinnableYesNo(target)), LogType.Info);

            Runes.CheckRunes();

            // Death Grip ?
            if (target.DistanceToSelf > 27 && BarMapper.IsSpellReadyById(49576))
            {
                MoveHelper.MoveToUnit(target, 27);
                MoveHelper.ReleaseKeys();
                CombatEngine.Log(string.Format("[Frosty]: Can't be arsed running {0} yards. Going to grip {1} towards me instead.", Math.Round((decimal)target.DistanceToSelf, 1), target.Name), LogType.Info);
                BarMapper.CastSpell("Death Grip");
            }

            Runes.CheckRunes();

            MoveHelper.MoveToUnit(target, CombatEngine.MeleeDistance);

            if (!ObjectManager.MyPlayer.IsAutoAttacking)
                target.Interact();

            return PullResult.Success;
        }
    }
}
